import { Component, ComponentType, lazy } from 'react';
import { RouteObject } from 'react-router-dom';
import Login from '@/pages/login';
import NotFound from '@/pages/notFound';


// 使用交叉类型扩展RouteObject
export type IRoute = RouteObject & {
  /**
   * 是否是菜单项
   * @default true
   */
  isMenu?: boolean;

  /**
   * 生成菜单的姓名
   */
  name: string;

  component: ComponentType;

  /**
   * 是否触发守卫逻辑
   * @default true
   */
  needGuard?: boolean;
  children?: IRoute[];

}

interface IRouteConfig {
  routes: IRoute[]
}

const routeConfig: IRouteConfig = {
  routes: [
    {
      name: 'home',
      path: '/',
      component: lazy(()=>import('../pages/home'))
    },

    {
      name: 'other',
      path: '/other',
      component: lazy(()=>import('../pages/other'))
    },
    {
      name: 'login',
      path: '/login',
      component: Login
    },
    {
      name: '404',
      path: '/*',
      component: NotFound,
      isMenu: false,
    }
  ]
}

export default routeConfig;

